<?php
//	$extra_part = $_GET['extra_part'];
	$acc_id     = '529135898';
	$token      =  'fckRLYTGOWtVsrdR%2FR6k09qdzpk%3D';
	$mp_op_od = "436926097";

	// Submit those variables to the server
	$url  = 'https://www.mercadopago.com/mla/sonda';

	//$data [] = 'seller_op_id=' . urlencode ( $extra_part );
	$data [] = 'mp_op_id=' . $mp_op_id;	
	$data [] = 'acc_id=' . urlencode ( $acc_id );
	$data [] = 'sonda_key=' . urlencode ( $token );
	$qs = implode ( '&', $data );

	$result = micurl($qs,$url);
	$doc = new SimpleXMLElement($result['response']);

	//--- Objeto devuelto:
/*
		SimpleXMLElement Object (
		    [message] => OK
		    [operation] => SimpleXMLElement Object (
		            [seller_op_id]   => 11-2-2012-07
		            [mp_op_id]       => 435538303
		            [acc_id]         => 529135898
		            [status]         => P
		            [status_description] => in_process
		            [item_id]        => 2%257C2012-07
		            [name]           => Plan+500+2012-07
		            [price]          => 300
		            [shipping_amount] => 0
		            [additional_amount] => 0
		            [total_amount]   => 300
		            [extra_part]     => 11-2-2012-07
		            [payment_method] => OFF
		        )
		)
		Client_id: 13103
		Client_secret: 07mGvmOJuadpsWsz499GyDtg8gyaDBnK
		$acc_id     = '529135898';
		$token      =  'fckRLYTGOWtVsrdR%2FR6k09qdzpk%3D';
		
*/


	$message        = $doc->message; 
	$seller_op_id   = $doc->operation->seller_op_id;
	$mp_op_id       = $doc->operation->mp_op_id;
	$acc_id         = $doc->operation->acc_id;
	$status         = $doc->operation->status;
	$status_description = $doc->operation->status_description;
	$item_id        = $doc->operation->item_id;
	$name           = $doc->operation->name;
	$price          = $doc->operation->price;
	$total_amount   = $doc->operation->total_amount;	
	$payment_method = $doc->operation->payment_method;	
	echo "Estado Reporte: $message<br>";
	echo "Estado del Pago: $status_description<br>";

	$fp = fopen('resultado.txt', 'a');
		fwrite($fp, "Mensaje:$message\n");
		fwrite($fp, "Seller Op Id: $seller_op_id\n");
		fwrite($fp, "MP op id: $mp_op_id\n");
		fwrite($fp, "ACC id: $acc_id\n");
		fwrite($fp, "Status: $status\n");
		fwrite($fp, "Status Description: $status_description\n");
		fwrite($fp, "Item id: $item_id\n");
		fwrite($fp, "Name: $name\n");
		fwrite($fp, "Price: $price\n");
		fwrite($fp, "Total: $total_amount\n");
		fwrite($fp, "Payment Method: $payment_method\n");
	fclose($fp);



	function micurl($qs,$url){
		$handler = curl_init ();
		curl_setopt ( $handler, CURLOPT_URL, $url );
		curl_setopt ( $handler, CURLOPT_POST, true );
		curl_setopt ( $handler, CURLOPT_POSTFIELDS, $qs );
		curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
		$response = curl_exec ( $handler );
		$return = array ('response' => $response, 'data' => curl_getinfo ( $handler ) );
		curl_close ( $handler );
		return $return;
	}

?>